// 抽象工厂：手机工厂
class PhoneFactory {
  createPhone() {}
}

// 抽象产品：手机
class Phone {
  os() {}
  hardware() {}
}

// 具体产品：小米品牌的手机
class XiaomiPhone extends Phone {
  constructor() {
    super()
    this.brand = '小米'
  }
  os() {
    console.log('小米的os发挥作用')
  }
  hardware() {
    console.log('小米的硬件发挥作用')
  }
}

// 具体工厂：小米品牌的手机工厂
class XiaomiPhoneFactory extends PhoneFactory {
  createPhone() {
    return new XiaomiPhone()
  }
}

const myXiaomiPhone = new XiaomiPhoneFactory().createPhone()
console.log(myXiaomiPhone)
myXiaomiPhone.os()
myXiaomiPhone.hardware()
